"nodejs";

const fs = require("fs");
const https = require('https');
var url = "https://gitee.com/luoleitest/serial-number/raw/master/test.MP4"
https.get(url, (res) => {
    // Open file in local filesystem
    const file = fs.createWriteStream('test1.MP4');
    // Write data into local file
    console.log(file)
    res.pipe(file);
    // Close the file
    file.on('finish', () => {
        file.close();
        console.log('File downloaded!');
    });
}).on("error", (err) => {
    console.log("Error: ", err.message);
});
//设置联网超时为10s
// threads.start(function () {
//     var url = "https://gitee.com/luoleitest/serial-number/raw/master/test.MP4"
//     let res = http.get(url)
//     log(res)
//     if (res.statusCode != 200) {
//         log(res.statusCode)
//         toastLog('下载失败')
//         exit()
//     }
//     let codeStr = res.body.string()
//     files.write("/sdcard/脚本/test.MP4", codeStr);

// })

